package com.face.console.dao;

import com.face.console.pojo.dto.MenuDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MenuDtoMapper {
    @Delete({
            "delete from face_menu",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into face_menu (id, pid, menu_name, ",
            "m_describe, m_code,url,m_type)",
            "values (#{id,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{menuName,jdbcType=VARCHAR}, ",
            "#{mDescribe,jdbcType=VARCHAR}, #{mCode,jdbcType=VARCHAR}, #{var,jdbcType=VARCHAR}),#{mType,jdbcType=TINYINT},"
    })
    int insert(MenuDto record);

    int insertSelective(MenuDto record);

    @Select({
            "select",
            "id, pid, menu_name, m_describe, m_code,url,m_type",
            "from face_menu",
            "where id = #{id,jdbcType=BIGINT}"
    })
//    @ResultMap("com.face.console.dao.MenuDtoMapper.BaseResultMap")
    MenuDto selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(MenuDto record);

    @Update({
            "update face_menu",
            "set pid = #{pid,jdbcType=BIGINT},",
            "menu_name = #{menuName,jdbcType=VARCHAR},",
            "m_describe = #{mDescribe,jdbcType=VARCHAR},",
            "m_code = #{mCode,jdbcType=VARCHAR},",
            "url = #{mCode,jdbcType=VARCHAR},",
            "m_type = #{mType,jdbcType=TINYINT}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MenuDto record);

    //根据pid查询菜单全部信息
    @Select({" select",
            "id, pid, menu_name menuName, m_describe mDescribe, m_code mCode,url,m_type",
            "from face_menu ",
            "where  pid = ${pid}"})
   List<MenuDto> queryMenuList(@Param("pid") Long pid);

    @Select({" select",
            "id, pid, menu_name menuName, m_describe mDescribe, m_code mCode,url,m_type mType",
            "from face_menu "})
    List<MenuDto> queryAllMenus();
}